package org.apache.flink.runtime.resourceprovider;

import java.io.Serializable;
import java.util.Collections;

/** Payload for heartbeats sent from the TaskExecutor to the ResourceConsumer. */
public class ResourceProviderToResourceConsumerHeartbeatPayload implements Serializable {

    private static final long serialVersionUID = 525146950563585444L;

    private final AccumulatorReport accumulatorReport;

    private final ResourceConsumptionReport executionDeploymentReport;

    public ResourceProviderToResourceConsumerHeartbeatPayload(
            AccumulatorReport accumulatorReport,
            ResourceConsumptionReport executionDeploymentReport) {
        this.accumulatorReport = accumulatorReport;
        this.executionDeploymentReport = executionDeploymentReport;
    }

    public AccumulatorReport getAccumulatorReport() {
        return accumulatorReport;
    }

    public ResourceConsumptionReport getExecutionDeploymentReport() {
        return executionDeploymentReport;
    }

    public static ResourceProviderToResourceConsumerHeartbeatPayload empty() {
        return new ResourceProviderToResourceConsumerHeartbeatPayload(
                new AccumulatorReport(Collections.emptyList()),
                new ResourceConsumptionReport(Collections.emptySet()));
    }

    @Override
    public String toString() {
        return "TaskExecutorToResourceConsumerHeartbeatPayload{"
                + "accumulatorReport="
                + accumulatorReport
                + ", executionDeploymentReport="
                + executionDeploymentReport
                + '}';
    }
}
